package com.thinkgem.jeesite.common.frame.rpc.listener;

import com.thinkgem.jeesite.common.frame.rpc.factory.RPCWebServiceFactory;
import com.thinkgem.jeesite.common.utils.SpringContextHolder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Created by liufeng on 2016/6/6.
 */
public class RPCListener implements ServletContextListener{

    private transient Log logger = LogFactory.getLog(this.getClass());


    @Override
    public void contextInitialized(ServletContextEvent sce) {

        while (SpringContextHolder.getApplicationContext()==null){
            try {
                logger.info("applicationContext为空，休眠1000毫秒");
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new Error("RPCListener初始化失败，applicationContext为空");
            }
        }
        //扫描WebService
        RPCWebServiceFactory.scanWebService();


    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {



    }
}
